open Castling;;

module CharPG = ParserGenerator (CharToken);;
open CharPG;;

let rec term = lazy !! (
	one_of ~name:"expr" [
		"", skip (element '(') >> expr >> skip (element ')');
		"call", term >> position_with (element '(') >> expr >> position_of (element ')');
		"term", element '1']
) and right = lazy !! (
	one_of ~name:"expr" [
		"", term;
		"pow", term >> element '^' >> right]
) and expr = lazy !! (
	one_of ~name:"expr" [
		"", right;
		"add", expr >> element '+' >> right;
		"sub", expr >> element '-' >> right]
);;

debug := true;;
runtime_debug := true;;
generate expr;;
